package org.university.entity;

import io.swagger.annotations.ApiModelProperty;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.time.LocalTime;

/**
 * @TableName classroom_assignment
 */
@Entity
@Table(name = "classroom_assignment")
@Data
public class ClassroomAssignment implements Serializable {

    @Id
    @NotNull(message = "[]不能为空")
    @ApiModelProperty("")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer assignmentId;
    /**
     * 课程ID
     */
    @NotNull(message = "[课程ID]不能为空")
    @ApiModelProperty("课程ID")
    private Integer classId;
    /**
     * 教室ID
     */
    @NotNull(message = "[教室ID]不能为空")
    @ApiModelProperty("教室ID")
    private Integer classroomId;
    /**
     * 星期（1-7）
     */
    @NotNull(message = "[星期（1-7）]不能为空")
    @ApiModelProperty("星期（1-7）")
    @Column(name = "day_of_week", columnDefinition = "TINYINT(1)")
    private DayOfWeek dayOfWeek;
    /**
     * 开始时间
     */
    @NotNull(message = "[开始时间]不能为空")
    @ApiModelProperty("开始时间")
    private LocalTime startTime;
    /**
     * 结束时间
     */
    @NotNull(message = "[结束时间]不能为空")
    @ApiModelProperty("结束时间")
    private LocalTime endTime;
    /**
     * 开设学期
     */
    @NotBlank(message = "[开设学期]不能为空")
    @Size(max = 30, message = "编码长度不能超过30")
    @ApiModelProperty("开设学期")
    @Length(max = 30, message = "编码长度不能超过30")
    private String semester;

    @Column(name = "deleted", columnDefinition = "tinyint(1) default 0")
    @ApiModelProperty("是否已删除")
    private Integer deleted = 0;

    @Getter
    @AllArgsConstructor
    public enum DayOfWeek {
        MONDAY(1, "周一"),
        TUESDAY(2, "周二"),
        WEDNESDAY(3, "周三"),
        THURSDAY(4, "周四"),
        FRIDAY(5, "周五"),
        SATURDAY(6, "周六"),
        SUNDAY(7, "周日");

        private final int code;
        private final String name;
    }
}
